#pragma once
#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <cstring>
#include <string>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <functional>
#include <unistd.h>
#include "Log.hpp"
using namespace std;
class INETADDR
{
public:
    INETADDR(struct sockaddr_in &addr)
        : _addr(addr)
    {
        _port = ntohs(_addr.sin_port);
        _ip = inet_ntoa(_addr.sin_addr);
    }
    uint16_t Port()
    {
        return _port;
    }
    string IP()
    {
        return _ip;
    }
    string StringAddr()
    {
        return _ip + ":" + to_string(_port);
    }
    const struct sockaddr_in& NetAddr()
    {
        return _addr;
    }
    bool operator==(INETADDR& addr)
    {
        return addr._ip == _ip && addr._port == _port;
    }
    
    ~INETADDR()
    {
    }

private:
    struct sockaddr_in _addr;
    uint16_t _port;
    string _ip;
};